﻿#include "C_GS_MainMenu.h"
#include "C_FSM.h"
#include "C_Label.h"
#include "C_GS_Intro.h"
#include "C_TextButton.h"
#include "C_CheckBox.h"
#include "C_ProgressBar.h"
#include "C_PeriodicTable.h"

#include "C_SQLite.h"
#include "C_SQLiteQuery.h"

C_GS_MainMenu::C_GS_MainMenu()
{
	this->setType(GAME_STATE_MENU);

	m_widget.setPos(0.0f, 0.0f);
	m_widget.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
	m_widget.setContainerType(gui::CONTAINER_VERTICAL);
	m_widget.setVerticalAlign(gui::GRID_MIDDLE);
	m_widget.setHorizontalAlign(gui::GRID_LEFT);
	m_widget.setPadding(10.0f);
	m_widget.setMargin(50.0f, 10.0f, 10.0f, 10.0f);

	//gui::C_Label *wLabel = new gui::C_Label();
	//wLabel->setText(L"Меню");
	//wLabel->setColorText(200, 200, 200, 255);
	//wLabel->setTextSize(35);
	//m_widget.addWidget(wLabel);

	//gui::C_TextButton *wCmdContinueGame = new gui::C_TextButton();
	//wCmdContinueGame->setCapture(L"Продолжить");
	//wCmdContinueGame->setCommand(cmd_onClick_ContinueGame);
	//m_widget.addWidget(wCmdContinueGame);

	//gui::C_TextButton *wCmdNewGame = new gui::C_TextButton();
	//wCmdNewGame->setCapture(L"Новая игра");
	//wCmdNewGame->setCommand(cmd_onClick_NewGame);
	//m_widget.addWidget(wCmdNewGame);

	//gui::C_TextButton *wCmdSettings = new gui::C_TextButton();
	//wCmdSettings->setCapture(L"Настройки");
	//wCmdSettings->setCommand(cmd_onClick_Settings);
	//m_widget.addWidget(wCmdSettings);

	//gui::C_TextButton *wCmdExit = new gui::C_TextButton();
	//wCmdExit->setCapture(L"Выход");
	//wCmdExit->setCommand(cmd_onClick_Exit);
	//m_widget.addWidget(wCmdExit);

	//gui::C_Label *wLabel = new gui::C_Label();
	//wLabel->setText(L"Меню");
	//wLabel->setColorText(200, 200, 200, 255);
	//wLabel->setTextSize(35);
	//m_widget.addWidget(wLabel);

	gui::C_ProgressBar *wBar = new gui::C_ProgressBar();
	wBar->setSize(400.0f, 50.0f);
	wBar->increase(0);
	m_widget.addWidget(wBar);

	gui::C_Widget *wWid = new gui::C_Widget();
	wWid->setContainerType(gui::CONTAINER_HORIZONTAL);
	wWid->setVerticalAlign(gui::GRID_MIDDLE);
	wWid->setHorizontalAlign(gui::GRID_LEFT);
	wWid->setPadding(20.0f);

	gui::C_TextButton *wCmdDec = new gui::C_TextButton();
	wCmdDec->setCapture(L"レス(less)");
	wCmdDec->setCommand(std::bind(&gui::C_ProgressBar::decreaseOne, wBar));
	wWid->addWidget(wCmdDec);

	gui::C_TextButton *wCmdInc = new gui::C_TextButton();
	wCmdInc->setCapture(L"もっと(more)");
	wCmdInc->setCommand(std::bind(&gui::C_ProgressBar::increaseOne, wBar));
	wWid->addWidget(wCmdInc);

	m_widget.addWidget(wWid);

	gui::C_Label *wLabel = new gui::C_Label();
	wLabel->setText(L"Имя Фамилия");
	wLabel->setColorText(200, 200, 200, 255);
	wLabel->setTextSize(25);
	m_widget.addWidget(wLabel);

}


C_GS_MainMenu::~C_GS_MainMenu()
{
}

void C_GS_MainMenu::handleEvent(sf::Event e)
{
	VC_Drawable::handleEvent(e);

	m_widget.handleEvent(e);
	m_rect.handleEvent(e);
}

void C_GS_MainMenu::render()
{
	GLfloat vec[] =
	{
		100.0f, 100.0f,
		100.0f, 500.0f,
		500.0f, 100.0f,
		500.0f, 500.0f
	};


	//m_rect.render();

	m_widget.render();
}

void C_GS_MainMenu::update()
{
}



void cmd_onClick_ChangeState()
{
	VC_GameState::fsm()->setChangeState(new C_GS_Intro());
}

void cmd_onClick_ContinueGame()
{

}
void cmd_onClick_NewGame()
{

}
void cmd_onClick_Settings()
{

}

void cmd_onClick_Exit()
{
	exit(0);
}
